<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg">
  <head>
    <title>Creating HTML nodes</title>
    <link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
    <link rel="stylesheet" type="text/css" href="kawa.css"/>
    <script src="kawa-ebook.js" type="text/javascript"/>
    <meta name="generator" content="DocBook XSL-NS Stylesheets V1.79.1"/>
    <link rel="prev" href="Formatting-XML.xhtml" title="Formatting XML"/>
    <link rel="next" href="Creating-XML-nodes.xhtml" title="Creating XML nodes"/>
  </head>
  <body>
    <header/>
    <section class="sect1" title="Creating HTML nodes" epub:type="subchapter" id="Creating-HTML-nodes">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both">Creating HTML nodes</h2>
          </div>
        </div>
      </div>
      <p>The <code class="literal">html</code> prefix names a special namespace
(see <a class="link" href="Namespaces.xhtml" title="Namespaces and compound symbols">Namespaces</a>) of functions to create HTML element nodes.
For example, <code class="literal">html:em</code> is a constructor that
when called creates a element node whose tag is <code class="literal">em</code>.
If this element node is formatted as HTML, the
result has an <code class="literal">&lt;em&gt;</code> tag.
</p>
      <p class="synopsis" kind="Syntax"><span class="kind">Syntax</span><span class="ignore">: </span><a id="idm139667870670704" class="indexterm"/> <code class="function">html:<em class="replaceable"><code>tag</code></em></code> <em class="replaceable"><code>attributes</code></em> <em class="replaceable"><code>...</code></em> <em class="replaceable"><code>content</code></em> <em class="replaceable"><code>...</code></em></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>Creates an element node whose tag is <em class="replaceable"><code>tag</code></em>.
The parameters are first zero or more attributes, followed
by zero of more child values.
An attribute is either an attribute value (possibly
created using <code class="literal">make-attribute</code>), or a pair of arguments:
A keyword followed by the attribute value.
Child values are usually either strings (text content),
or nested element nodes, but can also be comment or processing-instruction
nodes.
</p>
          <pre class="screen">(html:a href: "http://gnu.org/" "the "(html:i "GNU")" homepage")
</pre>
        </blockquote>
      </div>
      <p>The compound identifier <code class="literal">html:<em class="replaceable"><code>tag</code></em></code> is actually
a type: When you call it as a function you’re using Kawa’s
standard coercion of a type to its constructor function.
This means you can do type tests:
</p>
      <pre class="screen">(define some-node ...)
(if (instance? some-node html:blink)
  (error "blinking not allowed!"))
</pre>
      <p>Object identity is currently not fully specified.  Specifically,
it is undefined if a nested (child) element node is copied
“by value” or “by reference”.  This is related to whether
nodes have a parent reference.  In the XPath/XQuery data model
nodes do have a parent reference, and child nodes are conceptually
copied.  (In the actual implemention copying is commonly avoided.)
Kawa/Scheme currently followed the XQuery copying semantics,
which may not be the most appropriate for Scheme.
</p>
    </section>
    <footer>
      <div class="navfooter">
        <p>
          Up: <a accesskey="u" href="XML-tools.xhtml">Working with XML and HTML</a></p>
        <p>
        Previous: <a accesskey="p" href="Formatting-XML.xhtml">Formatting XML</a></p>
        <p>
        Next: <a accesskey="n" href="Creating-XML-nodes.xhtml">Creating XML nodes</a></p>
      </div>
    </footer>
  </body>
</html>
